package com.qing.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;

import com.qing.service.LeaveWordService;
import com.qing.pojo.LeaveWord;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author qinghua
 * @since 2022-06-06
 */
@RestController
@RequestMapping("/leave-word")
public class LeaveWordController {
    @Autowired
    private LeaveWordService leaveWordService;

    @PostMapping("/insert")
    public Boolean save(@RequestBody LeaveWord leaveWord) {
        return leaveWordService.saveOrUpdate(leaveWord);
    }

    @GetMapping("/deleteById/{id}")
    public Boolean delete(@PathVariable Integer id) {
        return leaveWordService.removeById(id);
    }

    @GetMapping("/queryAll")
    public List<LeaveWord> queryAll() {
        return leaveWordService.list(new QueryWrapper<LeaveWord>().orderByDesc("create_time"));
    }

    @GetMapping("/queryById/{id}")
    public LeaveWord findOne(@PathVariable Integer id) {
        return leaveWordService.getById(id);
    }

}

